package org.jeecg.modules.wlhy.hypfaccount.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.wlhy.hypfaccount.entity.HyPfAccount;
import org.jeecg.modules.wlhy.hypfaccount.mapper.HyPfAccountMapper;
import org.jeecg.modules.wlhy.hypfaccount.service.IHyPfAccountService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @Description: hy_pf_account
 * @Author: jeecg-boot
 * @Date:   2022-05-30
 * @Version: V1.0
 */
@Service
public class HyPfAccountServiceImpl extends ServiceImpl<HyPfAccountMapper, HyPfAccount> implements IHyPfAccountService {

    @Override
    public HyPfAccount getByUidAndUtype(String uid, String utype) {
        return this.getOne(new QueryWrapper<HyPfAccount>().eq("uid",uid).eq("utype",utype));
    }

    @Override
    public HyPfAccount getCustomerAccount(String customerId) {
        return this.getByUidAndUtype(customerId,"2");
    }

    @Override
    public HyPfAccount getDriverAccount(String driverId) {
        return this.getByUidAndUtype(driverId,"4");
    }

    @Override
    public HyPfAccount getCarrierAccount(String carrierId) {
        return this.getByUidAndUtype(carrierId,"5");
    }

    @Override
    public HyPfAccount getCompanyAccount(String companyId) {
        return this.getByUidAndUtype(companyId,"9");
    }

    @Override
    public List<HyPfAccount> getDriverAccounts(Set<String> uidSet) {
        return this.list(new QueryWrapper<HyPfAccount>().in("uid",uidSet).eq("utype","4"));
    }

    @Override
    public List<HyPfAccount> getCarrierAccounts(Set<String> uidSet) {
        return this.list(new QueryWrapper<HyPfAccount>().in("uid",uidSet).eq("utype","5"));
    }

    @Override
    public List<HyPfAccount> getCompanyAccounts(Set<String> uidSet) {
        return this.list(new QueryWrapper<HyPfAccount>().in("uid",uidSet).eq("utype","9"));
    }
}
